// pages/default/default.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
      dotsFlag: true,
      msg: "欢迎！",
      bannerList: [
        {
          belongTo: null,
          id: 6,
          salePromotionEndTime: "2021-01-10T00:00:00",
          salePromotionImage: "/Content/UploadFiles/GoodsSalePromotionIMGS/banner04.jpg",
          salePromotionOrder: 0,
          salePromotionStartTime: "2020-12-31T00:00:00",
          salePromotionStatus: 1,
          salePromotionTitle: "2025五粮液元旦跨年活动",
          salePromotionUrl: ""
        },
        { imgSrc: "../../images/banner02.jpg" },
        { imgSrc: "../../images/banner03.jpg" }],
      grids: [
        {
          belongTo: null,
          cateCode: "01",
          cateDiscount: 1,
          cateIcon: "/Content/UploadFiles/GoodsCateIcon/zhlzh.png",
          cateInfo: "无",
          cateLevel: 1,
          cateName: "中华老字号",
          cateNameE: "zhlzh",
          cateOrder: 1,
          cateParentCode: "00",
          cateTag: "中华老字号",
          hasChild: 0,
          id: 1
        },
        { imgSrc: "/images/icon/mjgg.jpg", title: "蜜饯果干" },
        { imgSrc: "/images/icon/phsp.jpg", title: "膨化食品" },
        { imgSrc: "/images/icon/rgss.jpg", title: "肉干熟食" },
      ],
      array: [{
        message: 'foo',
      }, {
        message: 'bar'
      }]
    },
    getCode(e) {
      //存储当前点击的类别编码，并跳转到list
      let code = e.currentTarget.dataset.code;
      console.log(code);
      wx.setStorageSync('cateCode', code);    
      //跳转到list
      wx.switchTab({
        url: '/pages/list/list',
      })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      console.log("onLoad");
      var that = this
      //这里写服务器数据请求过程
      wx.request({
        url: 'https://kjxycode.zisu.edu.cn/InterfaceCommonForGoods/GetGoodsSalePromotionList',
        data: { token: "kjxy_Interface_2025" },
        method: "post",
        success: function (e) {
          let result = e.data.goodsSalePromotionList;
          console.log(result)
          that.setData({ bannerList: result });
        }
      })
      wx.request({
        url: 'https://kjxycode.zisu.edu.cn/InterfaceCommonForGoods/GetGoodsCateList',
        data: { token: "kjxy_Interface_2025" },
        method: "post",
        success: function (e) {
          let result = e.data.cateList;
          console.log(result);
          wx.setStorageSync('cateList', result)
          that.setData({ grids: result });
        }
      })
    },
  
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {
      console.log("onReady");
    },
  
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
      console.log("onShow");
    },
  
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {
      console.log("onHide");
    },
  
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {
      console.log("onUnLoad");
    },
  
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {
  
    },
  
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {
  
    },
  
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {
  
    }
  })